//package com.lemon.cloud.admin.mq;
//
//import com.lemon.cloud.comm.constants.GrayConstant;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.common.message.MessageExt;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.annotation.SelectorType;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.apache.rocketmq.spring.core.RocketMQTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.messaging.support.MessageBuilder;
//import org.springframework.stereotype.Component;
//
//import java.nio.charset.StandardCharsets;
//
//@Component
//    @RocketMQMessageListener(consumerGroup = "${rocketmq.consumer.testConsumerGroup}",
//        topic = "${rocketmq.consumer.testTopic}",
//        selectorType = SelectorType.TAG)
//@Slf4j
//public class TestConsumer implements RocketMQListener<MessageExt> {
//
//    @Autowired
//    private RocketMQTemplate rocketMQTemplate;
//
//    @Override
//    public void onMessage(MessageExt messageExt) {
//        log.info("来消息了：BrokerName:{},body:{},tag:{},userProperty:{}",
//                messageExt.getBrokerName(),
//                new String(messageExt.getBody(), StandardCharsets.UTF_8),
//                messageExt.getTags(),
//                messageExt.getUserProperty(GrayConstant.ROCKET_GRAY_FLAG)
//        );
//        if ("hello".equals(new String(messageExt.getBody(), StandardCharsets.UTF_8))){
//            rocketMQTemplate.convertAndSend("TopicTest", MessageBuilder.withPayload("second").build());
//        }
//    }
//
//}
